﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TestFile"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           attributeFormDefault="unqualified"
           elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">



  <xs:complexType name="DbConnectionType">
    <xs:attribute name="connectionName" type="xs:string" use="required"/>
    <xs:attribute name="connectionString" type="xs:string" use="required"/>
    <xs:attribute name="providerName" type="xs:string" use="required"/>
  </xs:complexType>


  <xs:complexType name="ExportSettingType" abstract="true">
    <xs:attribute name="exportRecordCount" type="xs:integer" use="optional"/>
    <xs:attribute name="wrapStringByCDATA" type="xs:boolean" use="optional"/>
  </xs:complexType>


  <xs:complexType name="GlobalSettingType">
    <xs:complexContent>
      <xs:extension base="ExportSettingType">
        <xs:sequence>
          <xs:element name="dbConnection" type="DbConnectionType" maxOccurs="unbounded" minOccurs="0" />
        </xs:sequence>
        <xs:attribute name="dbConnectionFile" type="xs:string" use="optional"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="ArgumentType" abstract="true">
    <xs:attribute name="name" type="xs:string" use="required"/>
  </xs:complexType>


  <xs:complexType name="DeclarationArgumentType">
    <xs:complexContent >
      <xs:extension base="ArgumentType">
        <xs:attribute name="direction" type="ArgumentDirectionType" use="required"/>
        <xs:attribute name="type" type="ArgumentDataType" use="required"/>
        <xs:attribute name="size" type="xs:int" use="optional"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="InputArgumentType">
    <xs:complexContent>
      <xs:extension base="ArgumentType">
        <xs:attribute name="value" type="xs:string" use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>



  <xs:complexType name="DeclarationArgumentListType">
    <xs:sequence>
      <xs:element name="argument" type="DeclarationArgumentType" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="InputArgumentListType">
    <xs:sequence>
      <xs:element name="argument" type="InputArgumentType" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="ProcDeclarationType">
    <xs:all>
      <xs:element name="remark" type="xs:string"  minOccurs="0"  />
      <xs:element name="arguments" type="DeclarationArgumentListType"  minOccurs="0" />
    </xs:all>
    <xs:attribute name="alias" type="xs:string" use="required"/>
    <xs:attribute name="name" type="xs:string" use="required"/>
    <xs:attribute name="dbConnection" type="xs:string" use="required"/>
    <xs:attribute name="namespace" type="xs:string" use="optional"/>
  </xs:complexType>


  <xs:complexType name="ProcDeclarationListType">
    <xs:sequence>
      <xs:element name="procDeclaration" type="ProcDeclarationType" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="SqlDeclarationType">
    <xs:all>
      <xs:element name="sql" type="xs:string"  />
      <xs:element name="remark" type="xs:string"  minOccurs="0"  />
      <xs:element name="arguments" type="DeclarationArgumentListType"  minOccurs="0" />
    </xs:all>
    <xs:attribute name="alias" type="xs:string" use="required"/>
    <xs:attribute name="dbConnection" type="xs:string" use="required"/>
  </xs:complexType>


  <xs:complexType name="SqlDeclarationListType">
    <xs:sequence>
      <xs:element name="sqlDeclaration" type="SqlDeclarationType" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="PerfCaseOutputSettingType">
    <xs:complexContent>
      <xs:extension base="ExportSettingType"></xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="PerfTestCaseType">
    <xs:all>
      <xs:element name="testCaseRemark" type="xs:string"  minOccurs="0"  />
      <xs:element name="inputArguments" type="InputArgumentListType"  minOccurs="0" />
      <xs:element name="outputSetting" type="PerfCaseOutputSettingType"  minOccurs="0" />
      <xs:element name="setup" type="SetupStatementListType"  minOccurs="0"  />
      <xs:element name="teardown" type="SetupStatementListType"  minOccurs="0"  />
    </xs:all>
    <xs:attribute name="testCaseName" type="xs:string" use="required"/>
    <xs:attribute name="statementAlias" type="xs:string" use="required"/>
    <xs:attribute name="testInSandbox" type="xs:boolean" use="optional"/>
    <xs:attribute name="ignoreThis" type="xs:boolean" use="optional"/>
    <xs:attribute name="tags" type="xs:string" use="optional"/>
  </xs:complexType>


  <xs:complexType name="PerfTestCaseListType">
    <xs:sequence>
      <xs:element name="perfTestCase" type="PerfTestCaseType" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ResultsetOutputFieldType">
    <xs:attribute name="name" type="xs:string" use="required"/>
    <xs:attribute name="outputName" type="xs:string" use="optional"/>
    <xs:attribute name="nullValuePlaceHolder" type="xs:string" use="optional"/>
  </xs:complexType>

  <xs:complexType name="ResultsetOutputSettingType">
    <xs:complexContent>
      <xs:extension base="ExportSettingType">
        <xs:sequence>
          <xs:element name="field" type="ResultsetOutputFieldType" maxOccurs="unbounded" minOccurs="0"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="ResultsetType">
    <xs:all>
      <xs:element name="inputArguments" type="InputArgumentListType"  minOccurs="0" />
      <xs:element name="outputSetting" type="ResultsetOutputSettingType"  minOccurs="0">
        <xs:unique name="FieldUniqueRule">
          <xs:selector xpath="./field"/>
          <xs:field xpath="@name"/>
        </xs:unique>
      </xs:element>
    </xs:all>
    <xs:attribute name="statementAlias" type="xs:string" use="required"/>
    <xs:attribute name="outputArgument" type="xs:string" use="required"/>
  </xs:complexType>


  <xs:complexType name="RunableStatementType">
    <xs:all>
      <xs:element name="inputArguments" type="InputArgumentListType"  minOccurs="0" />
      <xs:element name="remark" type="xs:string"  minOccurs="0"  />
    </xs:all>
    <xs:attribute name="statementAlias" type="xs:string" use="required"/>
  </xs:complexType>


  <xs:complexType name="PumpDestInputArgumentType">
    <xs:complexContent>
      <xs:extension base="ArgumentType">
        <xs:attribute name="value" type="xs:string" use="optional"/>
        <xs:attribute name="valueIsReferFieldName" type="xs:boolean" use="optional"/>
        <xs:attribute name="dateTimeFormat" type="xs:string" use="optional"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>


  <xs:complexType name="PumpDestInputArgumentListType">
    <xs:sequence>
      <xs:element name="argument" type="PumpDestInputArgumentType" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>



  <xs:complexType name="PumpDestStatementType">
    <xs:sequence>
      <xs:element name="inputArguments" type="PumpDestInputArgumentListType"  minOccurs="0" />
    </xs:sequence>
    <xs:attribute name="statementAlias" type="xs:string" use="required"/>
  </xs:complexType>


  <xs:complexType name="PumpActionType">
    <xs:all>
      <xs:element name="pumpSourceStatement" type="ResultsetType"  />
      <xs:element name="pumpDestinationStatement" type="PumpDestStatementType"    />
      <xs:element name="remark" type="xs:string"  minOccurs="0"  />
    </xs:all>
  </xs:complexType>


  <xs:complexType name="SetupStatementListType">
    <xs:sequence>
      <xs:choice maxOccurs="unbounded" minOccurs="0">
        <xs:element name="statement" type="RunableStatementType" />
        <xs:element name="dataPumpAction" type="PumpActionType" />
      </xs:choice>
    </xs:sequence>
  </xs:complexType>


  <xs:complexType name="UnitTestCaseType">
    <xs:all>
      <xs:element name="targetResultset" type="ResultsetType" />
      <xs:element name="referenceResultset" type="ResultsetType" />
      <xs:element name="testCaseRemark" type="xs:string"  minOccurs="0"  />
      <xs:element name="setup" type="SetupStatementListType"  minOccurs="0"  />
      <xs:element name="teardown" type="SetupStatementListType"  minOccurs="0"  />
    </xs:all>
    <xs:attribute name="testCaseName" type="xs:string" use="required"/>
    <xs:attribute name="assertion" type="AssertionType" use="required"/>
    <xs:attribute name="testInSandbox" type="xs:boolean" use="optional"/>
    <xs:attribute name="ignoreThis" type="xs:boolean" use="optional"/>
    <xs:attribute name="tags" type="xs:string" use="optional"/>
  </xs:complexType>

  <xs:complexType name="UnitTestCaseListType">
    <xs:sequence>
      <xs:element name="unitTestCase" type="UnitTestCaseType" maxOccurs="unbounded" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>



  <xs:complexType name="DbTestFixtureType">
    <xs:all>
      <xs:element name="usage" type="xs:string" minOccurs="0" />

      <xs:element name="globalSetting" type="GlobalSettingType">
        <xs:unique name="DbConnectionUniqueRule">
          <xs:selector xpath="./dbConnection"/>
          <xs:field xpath="@connectionName"/>
        </xs:unique>
      </xs:element>

      <xs:element name="procDeclarations" type="ProcDeclarationListType" minOccurs="0" >
        <xs:unique name="ProcDeclarationUniqueRule">
          <xs:selector xpath="./procDeclaration"/>
          <xs:field xpath="@alias"/>
        </xs:unique>
      </xs:element>

      <xs:element name="sqlDeclarations" type="SqlDeclarationListType" minOccurs="0">
        <xs:unique name="SqlDeclarationUniqueRule">
          <xs:selector xpath="./sqlDeclaration"/>
          <xs:field xpath="@alias"/>
        </xs:unique>
      </xs:element>

      <xs:element name="perfTestCases" type="PerfTestCaseListType" minOccurs="0">
        <xs:unique name="PerfCaseUniqueRule">
          <xs:selector xpath="./perfTestCase"/>
          <xs:field xpath="@testCaseName"/>
        </xs:unique>
      </xs:element>

      <xs:element name="unitTestCases" type="UnitTestCaseListType" minOccurs="0">
        <xs:unique name="UnitCaseUniqueRule">
          <xs:selector xpath="./unitTestCase"/>
          <xs:field xpath="@testCaseName"/>
        </xs:unique>
      </xs:element>
    </xs:all>
  </xs:complexType>


  <xs:element name="dbTestFixture" type="DbTestFixtureType">
  </xs:element>



  <xs:simpleType name="AssertionType">
    <xs:annotation>
      <xs:documentation>assertion type for unit test</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="NotCareResultset"/>
      <xs:enumeration value="StrictEqual"/>
      <xs:enumeration value="SetEqual"/>
      <xs:enumeration value="IsSupersetOf"/>
      <xs:enumeration value="IsProperSupersetOf"/>
      <xs:enumeration value="IsSubsetOf"/>
      <xs:enumeration value="IsProperSubsetOf"/>
      <xs:enumeration value="Overlaps"/>
      <!--<xs:enumeration value="InIntervalOfNumAxis"/>, use DecimalElementIsInNumAxis instead-->
      <xs:enumeration value="DecimalElementIsInNumAxis"/>
      <xs:enumeration value="DecimalElementIsEqual"/>
      <xs:enumeration value="DecimalElementIsGreater"/>
      <xs:enumeration value="DecimalElementIsGreaterOrEqual"/>
      <xs:enumeration value="DecimalElementIsLess"/>
      <xs:enumeration value="DecimalElementIsLessOrEqual"/>
      <!--<xs:enumeration value="RecordCountInIntervalOfNumAxis"/>, use RecordCountIsInNumAxis instead-->
      <xs:enumeration value="RecordCountIsInNumAxis"/>
	  <!--<xs:enumeration value="RecordCountEqual"/>, use RecordCountIsEqual instead-->
      <xs:enumeration value="RecordCountIsEqual"/>
      <xs:enumeration value="RecordCountIsGreater"/>
      <xs:enumeration value="RecordCountIsGreaterOrEqual"/>
      <xs:enumeration value="RecordCountIsLess"/>
      <xs:enumeration value="RecordCountIsLessOrEqual"/> 
    

      <xs:enumeration value="!StrictEqual"/>
      <xs:enumeration value="!SetEqual"/>
      <xs:enumeration value="!IsSupersetOf"/>
      <xs:enumeration value="!IsProperSupersetOf"/>
      <xs:enumeration value="!IsSubsetOf"/>
      <xs:enumeration value="!IsProperSubsetOf"/>
      <xs:enumeration value="!Overlaps"/>
      <!--<xs:enumeration value="!InIntervalOfNumAxis"/>, use !DecimalElementIsInNumAxis instead-->
      <xs:enumeration value="!DecimalElementIsInNumAxis"/>
      <xs:enumeration value="!DecimalElementIsEqual"/>
      <xs:enumeration value="!DecimalElementIsGreater"/>
      <xs:enumeration value="!DecimalElementIsGreaterOrEqual"/>
      <xs:enumeration value="!DecimalElementIsLess"/>
      <xs:enumeration value="!DecimalElementIsLessOrEqual"/>
      <!--<xs:enumeration value="!RecordCountInIntervalOfNumAxis"/>, use !RecordCountIsInNumAxis instead-->
      <xs:enumeration value="!RecordCountIsInNumAxis"/> 
      <!--<xs:enumeration value="!RecordCountEqual"/>, use !RecordCountIsEqual instead-->
      <xs:enumeration value="!RecordCountIsEqual"/>
	  <xs:enumeration value="!RecordCountIsGreater"/>
      <xs:enumeration value="!RecordCountIsGreaterOrEqual"/>
      <xs:enumeration value="!RecordCountIsLess"/>
      <xs:enumeration value="!RecordCountIsLessOrEqual"/>








    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ArgumentDirectionType">
    <xs:annotation>
      <xs:documentation>direction type of procedure argument</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="Input"/>
      <!--<xs:enumeration value="IN"/>-->
      <xs:enumeration value="InputOutput"/>
      <!--<xs:enumeration value="INOUT"/>-->
      <xs:enumeration value="Output"/>
      <!--<xs:enumeration value="OUT"/>-->
      <xs:enumeration value="Return"/>
      <!--<xs:enumeration value="RETURN"/>-->
      <xs:enumeration value="AnonymousOutput"/>

      <!--<xs:enumeration value="ClientSide"/>-->
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ArgumentDataType">
    <xs:annotation>
      <xs:documentation>Date type of procedure and sql argument </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">

      <!--Oracle data type-->
      <xs:enumeration value="ORA_CHAR"/>
      <xs:enumeration value="ORA_VARCHAR"/>
      <xs:enumeration value="ORA_VARCHAR2"/>
      <xs:enumeration value="ORA_NCHAR"/>
      <xs:enumeration value="ORA_NVARCHAR"/>
      <xs:enumeration value="ORA_NVARCHAR2"/>
      <xs:enumeration value="ORA_NUMBER"/>
      <xs:enumeration value="ORA_DATETIME"/>
      <xs:enumeration value="ORA_TIMESTAMP"/>
      <xs:enumeration value="ORA_TIMESTAMPLOCAL"/>
      <xs:enumeration value="ORA_TIMESTAMPWITHTZ"/>
      <xs:enumeration value="ORA_INTERVALDAYTOSECOND"/>
      <xs:enumeration value="ORA_INTERVALYEARTOMONTH"/>
      <xs:enumeration value="ORA_INT"/>
      <xs:enumeration value="ORA_CURSOR"/>
      <xs:enumeration value="ORA_FLOAT"/>
      <xs:enumeration value="ORA_REAL"/>
      <xs:enumeration value="ORA_DOUBLE"/>
      <xs:enumeration value="ORA_ROWID"/>



      <!--MS SQL server data type-->
      <xs:enumeration value="MSSQL_BIGINT"/>
      <xs:enumeration value="MSSQL_BIT"/>
      <xs:enumeration value="MSSQL_CHAR"/>
      <xs:enumeration value="MSSQL_DATETIME"/>
      <xs:enumeration value="MSSQL_DECIMAL"/>
      <xs:enumeration value="MSSQL_NUMERIC"/>
      <xs:enumeration value="MSSQL_FLOAT"/>
      <xs:enumeration value="MSSQL_INT"/>
      <xs:enumeration value="MSSQL_MONEY"/>
      <xs:enumeration value="MSSQL_NCHAR"/>
      <xs:enumeration value="MSSQL_NTEXT"/>
      <xs:enumeration value="MSSQL_NVARCHAR"/>
      <xs:enumeration value="MSSQL_REAL"/>
      <xs:enumeration value="MSSQL_GUID"/>
      <xs:enumeration value="MSSQL_SMALLDATETIME"/>
      <xs:enumeration value="MSSQL_SMALLINT"/>
      <xs:enumeration value="MSSQL_SMALLMONEY"/>
      <xs:enumeration value="MSSQL_TEXT"/>
      <xs:enumeration value="MSSQL_TIMESTAMP"/>
      <xs:enumeration value="MSSQL_TINYINT"/>
      <xs:enumeration value="MSSQL_VARCHAR"/>
      <xs:enumeration value="MSSQL_RECORDSET"/>
      <xs:enumeration value="MSSQL_DATE"/>
      <xs:enumeration value="MSSQL_TIME"/>
      <xs:enumeration value="MSSQL_DATETIME2"/>
      <xs:enumeration value="MSSQL_DATETIMEOFFSET"/>


      <!--Excel data type-->
      <xs:enumeration value="XLS_CHAR"/>
      <xs:enumeration value="XLS_NCHAR"/>
      <xs:enumeration value="XLS_DATE"/>
      <xs:enumeration value="XLS_DATETIME"/>
      <xs:enumeration value="XLS_CURRENCY"/>
      <xs:enumeration value="XLS_DECIMAL"/>
      <xs:enumeration value="XLS_SINGLE"/>
      <xs:enumeration value="XLS_DOUBLE"/>
      <xs:enumeration value="XLS_INT"/>
      <xs:enumeration value="XLS_RECORDSET"/>
      

      <!--MySQL data type-->
      <xs:enumeration value="MYSQL_DECIMAL"/>
      <xs:enumeration value="MYSQL_BYTE"/>
      <xs:enumeration value="MYSQL_INT16"/>
      <xs:enumeration value="MYSQL_INT32"/>
      <xs:enumeration value="MYSQL_FLOAT"/>
      <xs:enumeration value="MYSQL_DOUBLE"/>
      <xs:enumeration value="MYSQL_TIMESTAMP"/>
      <xs:enumeration value="MYSQL_INT64"/>
      <xs:enumeration value="MYSQL_INT24"/>
      <xs:enumeration value="MYSQL_DATE"/>
      <xs:enumeration value="MYSQL_TIME"/>
      <xs:enumeration value="MYSQL_DATETIME"/>
      <xs:enumeration value="MYSQL_YEAR"/>
      <xs:enumeration value="MYSQL_VARSTRING"/>
      <xs:enumeration value="MYSQL_BIT"/>
      <xs:enumeration value="MYSQL_NEWDECIMAL"/>
      <xs:enumeration value="MYSQL_ENUM"/>
      <xs:enumeration value="MySQL_SET"/>
      <xs:enumeration value="MYSQL_VARCHAR"/>
      <xs:enumeration value="MYSQL_STRING"/>
      <xs:enumeration value="MYSQL_UBYTE"/>
      <xs:enumeration value="MYSQL_UINT16"/>
      <xs:enumeration value="MYSQL_UINT32"/>
      <xs:enumeration value="MYSQL_UINT64"/>
      <xs:enumeration value="MYSQL_UINT24"/>
      <xs:enumeration value="MYSQL_TINYTEXT"/>
      <xs:enumeration value="MYSQL_RECORDSET"/>



      <!--Postgresql data type-->
      <xs:enumeration value="PGSQL_BIGINT"/>
      <xs:enumeration value="PGSQL_BOOLEAN"/>
      <xs:enumeration value="PGSQL_CHAR"/>
      <xs:enumeration value="PGSQL_DATE"/>
      <xs:enumeration value="PGSQL_DOUBLE"/>
      <xs:enumeration value="PGSQL_INTEGER"/>
      <xs:enumeration value="PGSQL_MONEY"/>
      <xs:enumeration value="PGSQL_NUMERIC"/>
      <xs:enumeration value="PGSQL_REAL"/>
      <xs:enumeration value="PGSQL_SMALLINT"/>
      <xs:enumeration value="PGSQL_TEXT"/>
      <xs:enumeration value="PGSQL_TIME"/>
      <xs:enumeration value="PGSQL_TIMESTAMP"/>
      <xs:enumeration value="PGSQL_VARCHAR"/>
      <xs:enumeration value="PGSQL_INET"/>
      <xs:enumeration value="PGSQL_REFCURSOR"/>
      <xs:enumeration value="PGSQL_BIT"/>
      <xs:enumeration value="PGSQL_TIMESTAMPTZ"/>
      <xs:enumeration value="PGSQL_UUID"/>
      <xs:enumeration value="PGSQL_INTERVAL"/>
      <xs:enumeration value="PGSQL_TIMETZ"/>
      <xs:enumeration value="PGSQL_NAME"/>
      <xs:enumeration value="MYSQL_RECORDSET"/>

 


    </xs:restriction>
  </xs:simpleType>

</xs:schema>
